package com.gaussian.property.admin.module.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gaussian.property.admin.module.biz.service.MessageService;
import com.gaussian.property.admin.module.biz.vo.message.MessageForm;
import com.gaussian.property.admin.module.biz.vo.message.MessageReplyVo;
import com.gaussian.property.module.biz.vo.message.PageQueryMessageRequestDto;
import com.gaussian.property.module.biz.vo.message.PageQueryMessageResponse;
import com.songqi.common.core.domain.R;
import com.songqi.common.core.domain.page.PageDataInfo;
import com.songqi.common.web.request.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/4/19 15:49
 */
@Api(tags = "项目留言相关操作")
@Validated
@RestController
@RequestMapping("message/")
public class MessageController extends BaseController {

    @Resource
    private MessageService messageService;


    @ApiOperation("分页查询项目的留言")
    @GetMapping("pageQueryProjectMessage")
    public R<PageDataInfo<PageQueryMessageResponse>> pageQueryProjectMessage(PageQueryMessageRequestDto queryRequest){
        IPage<PageQueryMessageResponse> pageData = messageService.pageQueryProjectMessage(queryRequest);
        return getReturnDataTableInfo(pageData);
    }

    @ApiOperation("创建留言")
    @PostMapping("/createMessage")
    public R<Void> createMessage(@Validated @RequestBody MessageForm messageForm){
        messageService.createMessage(messageForm);
        return success();
    }


    @ApiOperation("查询留言的回复列表")
    @GetMapping("querySuggestionReply")
    public R<List<MessageReplyVo>> queryMessageReply(@ApiParam("项目留言id") String projectMessageId){
        return R.success(messageService.queryMessageReply(projectMessageId));
    }







}
